package jiangyeheng.h;

public class Main {
    public static void main(String[] args) {
        Action robot = new Robot(10.5, "R001");
        Action human = new Human("张三");
        Action pig = new Pig("黑色");

        Action[] actions = new Action[]{robot,human,pig};

        for( Action action : actions){
            action.work();
            action.eat();
            action.charge();
            action.sleep();
        }
    }
}
interface Action{
    void work();
    void eat();
    void sleep();
    void charge();
}

class Robot implements Action{
    private double current;
    private String id;

    public Robot(double current, String id) {
        this.current = current;
        this.id = id;
    }

    public Robot() {
    }

    @Override
    public void work() {
        System.out.println("机器人["+id+"]正在工作，当前电流为："+current+"A");
    }

    @Override
    public void sleep() {
        System.out.println("机器人["+id+"]正在休眠");
    }

    @Override
    public void eat() {
        System.out.println("机器人["+id+"]正在进行特殊能量补充");
    }

    @Override
    public void charge() {
        System.out.println("机器人["+id+"]正在充能");
    }

    public void setCurrent(double current) {
        this.current = current;
    }

    public void setId(String id) {
        this.id = id;
    }

    public double getCurrent() {
        return current;
    }

    public String getId() {
        return id;
    }
}

class Human implements Action{
    String name;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Human(String name) {
        this.name = name;
    }

    public Human() {
    }
    @Override
    public void charge() {
    }

    @Override
    public void eat() {
        System.out.println(name+"正在吃饭");
    }

    @Override
    public void sleep() {
        System.out.println(name+"正在睡觉");
    }

    @Override
    public void work() {
        System.out.println(name+"正在工作");
    }
}

class Pig implements Action{
    private String color;

    public Pig() {
        color="白色";
    }
    public Pig(String color) {
        this.color = color;
    }

    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }

    @Override
    public void charge() {

    }

    @Override
    public void eat() {
        System.out.println("这只"+color+"的猪正在吃饭");
    }

    @Override
    public void sleep() {
        System.out.println("这只"+color+"的猪正在睡觉");
    }

    @Override
    public void work() {

    }
}